<template>
 <table border="1">
    <thead>
        <tr>
            <td>房型名称</td>
            <td>房号</td>
        </tr>
    </thead>
    <tbody>
        <tr v-for="i in info">
            <td>{{ i.R_Name }}</td>
            <td>{{ i.RN_Num }}</td>
            <td>
                <input type="button" value="删除" @click="shanchu(i.RIN_Id)">
                <input type="button" value="详情" @click="xiangqin(i.RIN_Id)">
            </td>
        </tr>
    </tbody>
 </table>
</template>

<script setup lang="ts">
import {onMounted,ref} from 'vue'
import { useRoute,useRouter } from 'vue-router';
import axios from 'axios'
const use=useRoute();
const user=useRouter();
const info=ref([{
    "RN_Num": "",
    "RIN_Id": 4,
    "R_Name": ""
}])
onMounted(()=>{
    show()
})
const show=()=>{
    axios.get("https://localhost:7234/api/RoomInfoNumber/GetPageinfonumber")
    .then(res=>{
        info.value=res.data
    })
}
const shanchu=(RIN_Id:number)=>
{
    axios.delete("https://localhost:7234/api/RoomInfoNumber/DelByid",{
        params:{
            id:RIN_Id
        }
    })
    .then(res=>{
        if(res.data>0){
            alert("删除成功");
            show()
        }else{
            alert("删除失败")
        }
    })
}
const xiangqin=(RIN_Id:number)=>{
    user.push({
        name:"UpdaNuminfo",
        params:{
            id:RIN_Id
        }
    })
}

</script>

<style scoped>

</style>